<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>发布文章|<{$configcache['Title']}></title>
    <link rel="stylesheet" type="text/css" href="__CSS__/content.css"  />
    <link rel="stylesheet" type="text/css" href="__CSS__/public.css"  />
    <link rel="stylesheet" type="text/css" href="__ROOT__/dist/css/wangEditor.min.css">
    <script type="text/javascript" src="__JS__/jquery.js"></script>
    <script type="text/javascript" src="__JS__/Public.js"></script>
    <script type="text/javascript" src="__JS__/winpop.js"></script>
    <script type="text/javascript" src="__JS__/check.js"></script>
    <script type="text/javascript" src="__JS__/jquery-form.js"></script>
    <link rel="stylesheet" href="__JS__/Validform/images/style.css" type="text/css" media="all" />
    <script type="text/javascript" src="__JS__/Validform/images/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="__JS__/Validform/images/Validform_v5.3.2.js"></script>
    <script type="text/javascript" src="__JS__/Validform/plugin/passwordStrength/passwordStrength-min.js"></script>
    <script src="__JS__/jquery-form.js" type="text/javascript"></script>
    <script type="text/javascript" src="__JS__/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="__ROOT__/dist/js/wangEditor.js"></script>
    <!--<script type="text/javascript" src="__ROOT__/ueditor/ueditor.config.js"></script>-->
    <!--<script type="text/javascript" src="__ROOT__/ueditor/ueditor.all.min.js"> </script>-->
    <!--<script type="text/javascript" src="__ROOT__/ueditor/lang/zh-cn/zh-cn.js"></script>-->

    <script type="text/javascript" src="__JS__/PCASClass.js"></script>
    <script type="text/javascript" src="__JS__/layer/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="__JS__/layer/skin/layer.css" />
    <style type="text/css">
    #content .collect { width:auto; height:30px; border:none; padding:0px 18px; background:#f60; color:#fff; font-size:14px; font-family:"微软雅黑"; text-align:center; cursor:pointer; margin-left:30px; text-indent:0; }
    #content .collect:hover { background:#f90; }
    .editimg{height:100px;padding-left:10px;width: 100px;}
    .delimg{height: 20px;cursor: pointer;}
    .maindelimg{height: 20px;cursor: pointer;}
    </style>
    <script type="text/javascript">
    $(function(){
        $(".registerform").Validform({
            tiptype:2,
            /*表单验证*/
            tiptype:function(msg,o,cssctl){
                if(!o.obj.is("form")){
                    var objtip=o.obj.parent().find(".Validform_checktip");
                    cssctl(objtip,o.type);
                    objtip.text(msg);

                    var infoObj=o.obj.parent().find(".info");
                    if(o.type==2){
                        infoObj.fadeOut(200);
                    }else{
                        layer.closeAll('loading');
                        if(infoObj.is(":visible")){return;}
                        infoObj.css({
                            left:0,
                            top:-30
                        }).show().animate({
                            top:-27
                        },200);
                    }
                }
            },
        });
    })
    </script>
</head>
<body>
    <div id="content">
        <h1>首页 > 新闻管理 > 发布文章</h1>
        <h2>
            <div class="h2_left">
                <a href="__ACTION__" class="whole">全部</a>
                <a href="javascript:;" class="f5" onclick="f5();">刷新</a>
                <a href="javascript:;" onclick="location.href='__APP__/News/news'" class="uclass">列表</a>
                <a href="javascript:history.back();" class="Retreat">后退</a>
                <a href="javascript:history.go(1);" class="Advance">前进</a>
            </div>
        </h2>

        <form action="<{$url}>/eduWeb/news/sysupdateNews" method="post" enctype="multipart/form-data" class="registerform" id="form">
            <dl id="cdl">
                <dd><span class="dd_left" style="font-size: 18px;color: red;"><if condition = "$news.checkStatus eq 2">拒绝原因 : </span><span class="dd_right" style="font-size: 20px;color: red;"><{$news.comment}></span></if></dd>
                <dd>
                    <span class="dd_left">所属分类：</span>
                    <span class="dd_right">
                       <select class="select" name="newsType" style="width:86px;">
                           <volist name="clist" id="vo">
                               <option value="<{$vo.ID}>" <if condition="$vo.ID eq $news['newsType']">selected</if> ><{$vo.ClassName}></option>
                           </volist>
                       </select>
                   </span>
               </dd>
               <dd>
                <span class="dd_left">标题：</span>
                <span class="dd_right">
                   <input type="text" class="qtext title" name="title" value="<{$news.title}>" datatype="*2-80" errormsg="标题名称在2~80位之间！"  nullmsg="请填写标题名称！" maxlength=80 /><font class="defi defi-01"><span class="Validform_checktip"></span></font>
               </span>
           </dd>

           <dd>
            <span class="dd_left">是否置顶:</span>
            <span class="dd_right" style="margin-top:5px;">
                <input type="radio" name="isTop" value="1" <if condition="$news.isTop eq 1">checked</if>>是&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="isTop" value="0" <if condition="$news.isTop eq 0">checked</if>>否
            </span>
        </dd>

        <dd>
            <span class="dd_left">内容：</span>
            <span class="dd_right"><!--用父容器来控制宽度-->

                <textarea id="textarea" name="content" style="height:400px;max-height:500px;">
                    <p><{$news.content}></p>
                </textarea>
                <!--<div id="content"></div>-->
            </span>
        </dd>
        <dd><input type="submit" name="submit" value="提交" class="submit" /></dd>
    </dl>
    <input type="hidden" name="sid" value="<{$news.sid}>" class="user_id">
    <input type="hidden" name="userId" value="<{$userId}>" class="user_id">
    <input type="hidden" name="" value="<{:U('News/news')}>" id="jump">
</form>
</div>

<script>
var editor = new wangEditor('textarea');
    // 上传图片
    editor.config.uploadImgUrl = 'http://139.196.194.93:8001/eduWeb/image/upload';
    // 自定义上传事件
    editor.config.uploadImgFns.onload = function (resultText, xhr) {
        // resultText 服务器端返回的text
        // xhr 是 xmlHttpRequest 对象，IE8、9中不支持
        // 上传图片时，已经将图片的名字存在 editor.uploadImgOriginalName
        var originalName = editor.uploadImgOriginalName || '';
//	    var url = jQuery.parseJSON(resultText).keyUrl
        // 如果 resultText 是图片的url地址，可以这样插入图片：
        editor.command(null, 'insertHtml', '<img src="' + resultText + '" alt="' + originalName + '" style="max-width:100%;"/>');
        // 如果不想要 img 的 max-width 样式，也可以这样插入：
        // editor.command(null, 'InsertImage', resultText);
    };
    editor.create();
    $('#btn1').click(function () {
        // 获取编辑器区域完整html代码
        var html = editor.$txt.html();
//        var content = document.getElementById('content');
//        content.innerHTML = '<input type="hidden" name="mainPicKey" value="' + html + '"/>';

});
    function logo(file){
        $("#str").remove('.imgstr');
        $(".yuanimg1").hide();
        $('#str').show();
        var prevDiv = document.getElementById('str');
        if (file.files && file.files[0]){
            var reader = new FileReader();
            reader.onload = function(evt){
                img = evt.target.result;
                prevDiv.innerHTML = '<img src="' + evt.target.result + '" style="height:120px;"/>';
            };
            reader.readAsDataURL(file.files[0]);
        }
        else
        {
            prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'" style="height:120px;"></div>';
        }
    }

    $(document).on("change", "input[name=file]", logosub);
    function logosub() {
        //模拟form表单提交数据
        var prevDiv2 = document.getElementById('str2');
        var filepath=$("input[name='file']").val();
        var extStart=filepath.lastIndexOf(".");
        var ext=filepath.substring(extStart,filepath.length).toUpperCase();
        if(ext!=".jpeg"&&ext!=".jpg"&&ext!=".bmp"&&ext!=".png" &&ext!=".JPEG"&&ext!=".JPG"&&ext!=".BMP"&&ext!=".PNG"){
            alert("文件选择错误,图片类型必须是jpeg,jpg,bmp,png中的一种");
            var file = $("#file") ;
            file.after(file.clone().val(""));
            file.remove();
            $('#str').hide();
            return false;

        }
        var index = layer.load(1, {shade: [0.1,'#fff']});
        var fileObj = document.getElementById("file").files[0];
        //console.log(fileObj);return;

        var FileController = '<{$url}>/eduWeb/image/uploadImg';
        var form = new FormData();
        form.append("file", fileObj);

        var xhr = new XMLHttpRequest();
        xhr.open("post", FileController, true);
        xhr.onload = function (json) {
            var obj = jQuery.parseJSON(json.target.responseText);
            //console.log(obj);
            layer.closeAll('loading');
            alert('上传成功');
            prevDiv2.innerHTML = '<input type="hidden" name="mainPicKey" value="' + obj.key + '"/>';
        };
        xhr.send(form);
    }

    $(function(){
        $(document).ready(function(){
            $('#form').ajaxForm(function(data){
                var index = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });

                if(data.code =="2000" ){
                    layer.closeAll('loading');
                    alert(data.message);
                    var url = $('#jump').val();
                    window.location.href = url;
                    //console.log(data)
                }else{
                    layer.closeAll('loading');
                    alert(data.message);
                    //console.log(data);
                }
            });
        });
    });

    </script>
</body>
</html>
